package com.knoya.chejian.pda.module.outsourcing

import android.content.Context
import com.knoya.chejian.pda.contacts.Contacts
import com.knoya.chejian.pda.minterface.OnUserDataInterface
import com.knoya.chejian.pda.util.HttpUtil
import org.xutils.http.HttpMethod
import org.xutils.http.RequestParams
import org.xutils.x

class OutsourcingM : OutsourcingContract.OutsourcingMP{
    override fun putOutsourcing(context: Context, mlist: MutableList<OutsourcingBean>, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.OUTSOURCING)
        HttpUtil.getparams(context, params)
        HttpUtil.addtoken(params)
        for (i in 0 until mlist.size){
            params.addBodyParameter("outsourcing["+i+"][scan_string]", mlist[i].scrn_string, Contacts.BOUNDARY)
        }
        params.addBodyParameter("","", Contacts.BOUNDARY)
        params.addBodyParameter("status","new")
        x.http().post(params, HttpUtil.Call(context, onUserDataInterface))
    }

    override fun deleteOutsourcing(context: Context, mlist: MutableList<OutsourcingBean>, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.OUTSOURCING)
        HttpUtil.getparams(context, params)
        HttpUtil.addtoken(params)
        for (i in 0 until mlist.size){
            params.addBodyParameter("outsourcing["+i+"][scan_string]", mlist[i].scrn_string, Contacts.BOUNDARY)
        }
        params.addBodyParameter("","", Contacts.BOUNDARY)
        params.addBodyParameter("status","delete")
        x.http().post(params, HttpUtil.Call(context, onUserDataInterface))
    }
}